/**
 * Project Name:pums-ui
 * File Name:index.js
 * Package Name:infoRules
 * Description: 全局验证
 * Date:2019/2/25 14:13
 * Copyright (c) 2019, yxw@bostech.com.cn All Rights Reserved.
 */
import { isMobile, isPhone, validatenum, notChinese } from '@/util/validate'
// 验证联系电话
var checkPhoneNum = (rule, value, callback) => {
  if (!value || isMobile(value) || isPhone(value)) {
    callback();
  } else {
    callback(new Error('请输入正确的联系电话'));
  }
};

// 验证联系电话
var checkYear = (rule, value, callback) => {
  if (value && !validatenum(value, 2)) {
    callback();
  } else {
    callback(new Error('请输入正确的年份'));
  }
};
//验证密码是否存在中文
var checkChinese = (rule, value, callback) => {
  if (value && notChinese(value)) {
    callback();
  } else {
    callback(new Error('请输入正确的密码，不能为空和不能中文。'));
  }
};

// 规划相关验证信息
export const projectRules = {
  title: [{ required: true, message: "请输入规划名称", trigger: "blur" }],
  category: [
    { required: true, message: "请输入规划类型", trigger: "blur" }
  ],
  startDate: [
    { required: true, message: "请输入规划期限", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入规划期限", trigger: "blur" }
  ],
  orgCode: [
    {
      required: true, message: "请输入申报(牵头)单位", trigger: "blur"
    }
  ],
  approvingAuthorityLevel: [
    { required: true, message: "请选择审批机关级别", trigger: "blur" }
  ],
  approvingAuthorityNature: [
    { required: true, message: "请选择审批机关性质", trigger: "blur " }
  ],
  releaseDate: [
    { required: true, message: "请输入拟发布时间", trigger: "blur" }
  ],
  contactName: [
    { required: true, message: "请输入联系人姓名", trigger: "blur" }
  ],
  contactNumber: [
    { required: false, message: "请输入联系电话", trigger: "blur" }
  ],
  // contactNumber: [
  //   {validator: checkPhoneNum, trigger: "blur"}
  // ],
  financialSource: [
    { required: false, message: "请输入编制经费来源", trigger: "blur" }
  ],
  // scope: [{ required: false, message: "请输入规划范围", trigger: "blur" }],
  basis: [{ required: false, message: "请输入立项依据", trigger: "blur" }],
  content: [
    { required: false, false: "请输入主要内容", trigger: "blur" }
  ],
  planningLevel: [
    { required: true, message: "请输入拟发布层级", trigger: "blur" }
  ],
  areaCode: [
    { required: false, message: "请输入地区代码", trigger: "blur" }
  ]
};

// 成果验证相关验证
export const resultRules = {
  title: [{ required: true, message: "请输入规划名称", trigger: "blur" }],
  category: [
    { required: true, message: "请输入规划类型", trigger: "change" }
  ],
  startDate: [
    { required: true, message: "请输入规划期限", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入规划期限", trigger: "blur" }
  ],
  orgCode: [
    { required: false, message: "请输入申报(牵头)单位", trigger: "blur" }
  ],
  approvingAuthorityLevel: [
    { required: true, message: "请选择审批机关级别", trigger: "change" }
  ],
  approvingAuthorityNature: [
    { required: true, message: "请选择审批机关性质", trigger: "change" }
  ],
  releaseDate: [
    { required: true, message: "请输入发布时间", trigger: "blur" }
  ],
  contactNumber: [
    { required: false, message: "请输入联系电话", trigger: "blur" }
  ],
  // contactNumber: [
  //   {validator: checkPhoneNum, trigger: "blur"}
  // ],
  financialSource: [
    { required: false, message: "请输入编制经费来源", trigger: "blur" }
  ],

  // scope: [{ required: false, message: "请输入规划范围", trigger: "blur" }],
  basis: [{ required: false, message: "请输入立项依据", trigger: "blur" }],

  content: [
    { required: false, message: "请输入主要内容", trigger: "blur" }
  ],
  planningLevel: [
    { required: true, message: "请输入发布层级", trigger: "blur" }
  ],
  planningRank: [
    { required: true, message: "请输入发布等级", trigger: "blur" }
  ],
  areaCode: [
    { required: false, message: "请输入地区代码", trigger: "blur" }
  ],
  isOpen: [
    { required: true, message: "请选择是否公开", trigger: "blur" }
  ],
};

// 课题相关验证信息
export const subjectRules = {
  title: [
    { required: true, message: "请输入课题名称", trigger: "blur" }
  ],
  description: [
    { required: true, message: "请输入课题概述", trigger: "blur" }
  ],
};

// 课题相关验证信息
export const addSubjectRules = {
  title: [
    { required: true, message: "请输入课题名称", trigger: "blur" }
  ],
  description: [
    { required: true, message: "请输入课题概述", trigger: "blur" }
  ],
  startDate: [
    { required: true, message: "请输入开始时间", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入结束时间", trigger: "blur" }
  ],
};

// 课题征集相关验证信息
export const levyFormRules = {
  supportDeptName: [
    { required: true, message: "请输入征求部门", trigger: "blur" }
  ],
  txt: [
    { required: true, message: "请输入征集要求", trigger: "blur" }
  ],
  title: [
    { required: true, message: "请输入征求主题", trigger: "blur" }
  ],
};

// 课题征集相关验证信息
export const subjectlevyFormRules = {
  supportDeptName: [
    { required: true, message: "请输入征求部门", trigger: "blur" }
  ],
  content: [
    { required: true, message: "请输入征求说明", trigger: "blur" }
  ],
  title: [
    { required: true, message: "请输入征求主题", trigger: "blur" }
  ],
  contactName: [
    { required: true, message: "请输入联系人姓名", trigger: "blur" }
  ],
  contactNumber: [
    { required: true, message: "请输入联系人电话", trigger: "blur" }
  ],
  startDate: [
    { required: true, message: "请输入时间要求", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入截止时间", trigger: "blur" }
  ],
};

// 材料收集相关验证信息
export const collectionRules = {
  supportDeptName: [
    { required: true, message: "请输入征集部门", trigger: "blur" }
  ],
  text: [
    { required: true, message: "请输入征集要求", trigger: "blur" }
  ],
};

// 材料收集相关验证信息
export const reviewRules = {
  // fileNo: [
  //   {required: true, message: "请输入文号", trigger: "blur"}
  // ],
  askTheme: [
    { required: true, message: "请输入请示件主题", trigger: "blur" }
  ],
  askTime: [
    { required: true, message: "请选择请示时间", trigger: "blur" }
  ],
  askTitle: [
    { required: true, message: "请输入请示件名称", trigger: "blur" }
  ],
  openScope: [
    { required: true, message: "请选择拟发布范围", trigger: "blur" }
  ]
};

// 实施验证信息
export const pimRules = {
  name: [
    { required: true, message: "请输入模版名称", trigger: "blur" }
  ],
  category: [
    { required: true, message: "请选择类别", trigger: "blur" }
  ],
};
// 配置进度字段添加 -验证
export const addprogressFileRules = {
  displayWay: [
    { required: true, message: "请选择展现组件", trigger: "blur" }
  ],
  required: [
    { required: true, message: "请选择是否必填", trigger: "blur" }
  ],
};
// 实施验证信息
export const pimWorkingItemRules = {
  name: [
    { required: true, message: "请输入监测项名称", trigger: "blur" }
  ],
  submitPeriod: [
    { required: true, message: "请输入选择上报周期", trigger: "blur" }
  ],
  startDate: [
    { required: true, message: "请输入选择起止日期", trigger: "blur" }
  ],
  quantifiable: [
    { required: true, message: "请输入选择是否可量化", trigger: "blur" }
  ],

};
// 课题征求意见相关验证信息
export const subjectOpinionrules = {
  title: [
    { required: true, message: "请输入课题征求意见名称", trigger: "blur" }
  ],
  txt: [
    { required: true, message: "请输入课题征求意见描述", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入截止时间", trigger: "blur" }
  ],

};

// 课题征求意见相关验证信息
export const reportHistoryrules = {
  version: [
    { required: true, message: "请输入版本号", trigger: "blur" }
  ],
};

// 课题征求意见相关验证信息
export const collectionInfosrules = {
  updateReason: [
    { required: true, message: "请输入反馈内容", trigger: "blur" }
  ],
};

// 课题征求意见相关验证信息
export const versionrules = {
  subjectTitle: [
    { required: true, message: "请输入课题成果", trigger: "blur" }
  ],
  updateReason: [
    { required: true, message: "请输入修改说明", trigger: "blur" }
  ],
  needRelease: [
    { required: true, message: "请输入是否发布", trigger: "blur" }
  ],
};
// 课题征求意见相关验证信息
export const releaseFormRules = {
  openType: [
    { required: true, message: "请输入发布类型", trigger: "blur" }
  ],
};

// 课题征求意见相关验证信息
export const rejectFormRules = {
  opinion: [
    { required: true, message: "请输入补充理由", trigger: "blur" }
  ],
};

// 课题征求意见相关验证信息
export const collectionFeedbackRules = {
  opinion: [
    { required: true, message: "请输入反馈意见", trigger: "blur" }
  ],
};
// 课题征求意见相关验证信息
export const addPlanConnectionrules = {
  title: [
    { required: true, message: "请输入衔接主题", trigger: "blur" }
  ],
  content: [
    { required: true, message: "请选择衔接说明", trigger: "blur" }
  ],
  supportDeptName: [
    { required: true, message: "请选择衔接部门", trigger: "blur" }
  ],
};

// 课题征求意见相关验证信息
export const materialCollectionRules = {
  endDate: [
    { required: true, message: "请输入截止时间", trigger: "blur" }
  ],
  title: [
    { required: true, message: "请输入材料收集名称", trigger: "blur" }
  ],
  description: [
    { required: true, message: "请输入所需材料描述", trigger: "blur" }
  ],
  supportDeptName: [
    { required: true, message: "请选择责任部门", trigger: "blur" }
  ],
};
// 审批发布征集意见
export const releaseOpinionrules = {
  title: [
    { required: true, message: "请输入标题", trigger: "blur" }
  ],
  content: [
    { required: true, message: "请输入内容", trigger: "blur" }
  ]
};

// 专家评审验证信息
export const makeExpertRules = {
  conclusion: [
    { required: true, message: "请输入评审结论", trigger: "blur" }
  ],
  expertLeader: [
    { required: true, message: "请输入专家组长", trigger: "blur" }
  ],
  expertList: [
    { required: true, message: "请输入专家组成员名单", trigger: "blur" }
  ],
  reviewTime: [
    { required: true, message: "请输入评审时间", trigger: "blur" }
  ]
};

export const addTargetRules = {
  year: [
    { validator: checkYear, required: true, trigger: "blur" }
  ]
};
export const endSubjectRules = {
  title: [
    { required: true, message: "请输入结题申请名称", trigger: "blur" }
  ],
  description: [
    { required: true, message: "请输入结题申请说明", trigger: "blur" }
  ],
  openType: [
    { required: true, message: "请输入发布类型", trigger: "blur" }
  ]
};

export const planSubjectRules = {
  title: [
    { required: true, message: "请输入计划名称", trigger: "blur" }
  ],
};

export const planOpinionRules = {
  title: [
    { required: true, message: "请输入征求主题", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入截至时间", trigger: "blur" }
  ],
  content: [
    { required: false, message: "请输入征求说明", trigger: "blur" }

  ]
};

export const addProgramFormRules = {
  planningTitle: [
    { required: true, message: "请选择规划", trigger: "blur" }
  ],
  description: [
    { required: true, message: "请输入方案描述", trigger: "blur" }
  ],

};

export const addNormFormFormRules = {
  description: [
    { required: true, message: "请输入内容", trigger: "blur" }
  ],
  totalTarget: [
    { required: false, message: "请输入总目标", trigger: "blur" }
  ],
  totalTargetUnit: [
    { required: false, message: "请输入总目标单位", trigger: "blur" }
  ],
  startDate: [
    { required: true, message: "请输入开始年份", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入结束年份", trigger: "blur" }
  ],
  leadDeptName: [
    { required: true, message: "请输入牵头部门", trigger: "blur" }
  ],
  cooDeptName: [
    { required: false, message: "请输入配合部门", trigger: "blur" }
  ],
  quantifiable: [
    { required: true, message: "请选择是否可量化", trigger: "blur" }
  ],
  itemName: [
    { required: true, message: "请输入名称", trigger: "blur" }
  ],
  content: [
    { required: true, message: "请输入项目内容", trigger: "blur" }
  ],
  submitPeriod: [
    { required: true, message: "请选择时间类型", trigger: "blur" }
  ],
};

export const addNormFormFormRulesFalse = {
  description: [
    { required: false, message: "请输入内容", trigger: "blur" }
  ],
  totalTarget: [
    { required: false, message: "请输入总目标", trigger: "blur" }
  ],
  totalTargetUnit: [
    { required: false, message: "请输入总目标单位", trigger: "blur" }
  ],
  startDate: [
    { required: true, message: "请输入开始年份", trigger: "blur" }
  ],
  endDate: [
    { required: true, message: "请输入结束年份", trigger: "blur" }
  ],
  leadDeptName: [
    { required: true, message: "请输入牵头部门", trigger: "blur" }
  ],
  cooDeptName: [
    { required: false, message: "请输入配合部门", trigger: "blur" }
  ],
  quantifiable: [
    { required: true, message: "请选择是否可量化", trigger: "blur" }
  ],
  itemName: [
    { required: true, message: "请输入名称", trigger: "blur" }
  ],
  content: [
    { required: true, message: "请输入项目内容", trigger: "blur" }
  ],
  submitPeriod: [
    { required: true, message: "请选择时间类型", trigger: "blur" }
  ],
};

export const addNormFormFormRulesProject = {
  description: [
    { required: false, message: "请输入内容", trigger: "blur" }
  ],
  totalTarget: [
    { required: false, message: "请输入总目标", trigger: "blur" }
  ],
  totalTargetUnit: [
    { required: false, message: "请输入总目标单位", trigger: "blur" }
  ],
  startDate: [
    { required: false, message: "请输入开始年份", trigger: "blur" }
  ],
  endDate: [
    { required: false, message: "请输入结束年份", trigger: "blur" }
  ],
  leadDeptName: [
    { required: true, message: "请输入牵头部门", trigger: "blur" }
  ],
  cooDeptName: [
    { required: false, message: "请输入配合部门", trigger: "blur" }
  ],
  quantifiable: [
    { required: true, message: "请选择是否可量化", trigger: "blur" }
  ],
  itemName: [
    { required: true, message: "请输入名称", trigger: "blur" }
  ],
  content: [
    { required: true, message: "请输入项目内容", trigger: "blur" }
  ],
  submitPeriod: [
    { required: true, message: "请选择时间类型", trigger: "blur" }
  ],
};

export const reportOpinionFormRules = {
  content: [
    { required: false, message: "请输入调整内容", trigger: "blur" }
  ],
  reviseName: [
    { required: true, message: "请输入调整建议名称", trigger: "blur" }
  ],

};

export const subjectResultFormRules = {
  title: [
    { required: true, message: "请输入课题名称", trigger: "blur" }
  ],
  description: [
    { required: true, message: "请输入课题概述", trigger: "blur" }
  ],
  openType: [
    { required: true, message: "请选择共享范围", trigger: "blur" }
  ],
  deptName: [
    { required: true, message: "请选择牵头部门", trigger: "blur" }
  ],
  openDeptNames: [
    { required: true, message: "请选择公开部门", trigger: "blur" }
  ],

};

export const addReportFormRules = {
  reportFilesId: [
    { required: true, message: "请上传报告文件", trigger: "blur" }
  ],
  reportType: [
    { required: true, message: "请选择报告类型", trigger: "blur" }
  ],
  year: [
    { required: true, message: "请输入年份", trigger: "blur" }
  ],
  createUnit: [
    { required: true, message: "请选择起草单位", trigger: "blur" }
  ],
  draftTime: [
    { required: true, message: "请选择起草时间", trigger: "blur" }
  ],
};

export const addAdjustFormRules = {
  reviseName: [
    { required: true, message: "请输入调整建议名称", trigger: "blur" }
  ],
  content: [
    { required: true, message: "请输入调整内容", trigger: "blur" }
  ],
  contentFileIds: [
    { required: true, message: "请上传相关附件", trigger: "blur" }
  ],
};
